package com.sso.action;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.tools.util.RequestUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.tools.util.JSONUtils;
import com.tools.util.StrUtils;
import com.sso.entity.SysResourceRole;
import com.sso.manager.SysResourceRoleManager;

@Controller
@RequestMapping("res_role")
public class SysResourceRoleAction extends BaseAction{
	@Autowired
	private SysResourceRoleManager resourceRoleManager;

	@RequestMapping("selectRoleByResourceId")
	public void selectRoleByResourceId(HttpServletRequest request,HttpServletResponse response){
		String id = RequestUtils.getParameters(request,"id");
		if(StrUtils.isEmpty(id)){
			return;
		}
		Map<String,Object> filterMap = new HashMap<String, Object>();
		filterMap.put("resourceId", id.trim());
		List<SysResourceRole> list =resourceRoleManager.selectByProperty(filterMap);
		String arr = JSONUtils.toJsonInAttrbuite(list, "roleId");
		super.outputJsonString(arr, response);
	}
}
